package com.yanqu.road.server.cmd.banquet;

import com.yanqu.road.pb.worldmessage.WorldMessageProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.manger.banquet.BanquetMgr;
import com.yanqu.road.server.manger.player.WorldMessageMgr;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.Protocol;

import java.util.List;
import java.util.Map;

@Cmd(code = Protocol.S_BANQUET_SERVER_CHAT, desc = "请求聊天")
public class GetBanquetMessageCmd extends AbstractCommand {

	@Override
	public boolean parseData(YanQuMessage packet) throws Exception {
		return true;
	}

	@Override
	public void execute(GamePlayer player, YanQuMessage packet) throws Exception {

	}

	@Override
	public void sendData(GamePlayer player) {
		WorldMessageProto.BanquetMessageListResp.Builder messageList = WorldMessageProto.BanquetMessageListResp.newBuilder();
		Map<String, List<WorldMessageProto.WorldMessageTempMsg.Builder>> banquetMessageMsgList =  WorldMessageMgr.getBanquetMessageMsgList();
		for(String banquetId : banquetMessageMsgList.keySet()){
			if(!BanquetMgr.isBanquetOver(banquetId)){
				for (WorldMessageProto.WorldMessageTempMsg.Builder msg : banquetMessageMsgList.get(banquetId)){
					messageList.addDataList(msg);
				}
			}
		}
		player.sendPacket(Protocol.U_BANQUET_SERVER_CHAT, messageList);
	}
}
